package leetcode.greed;

//nums = [1,17,5,10,13,15,10,5,16,8]
//[3,3,3,2,5]
public class Test376 {

    public static void main(String[] args) {
        int[] nums = {0,0};
        System.out.println(wiggleMaxLength(nums));
    }

    public static int wiggleMaxLength(int[] nums) {
        int length = nums.length;
        if (length < 2){
            return length;
        }
        int index = 1;
        while (index < nums.length && nums[index] == nums[index-1]){
            index++;
        }
        if (index == nums.length){
            return 1;
        }
        int count = 2;
        boolean up  = nums[index]>nums[index-1];
        for (int i = index+1; i < length; i++) {
            if (up && nums[i]<nums[i-1]){
                count++;
                up= false;
            }
            if(!up &&  nums[i]>nums[i-1]){
                count++;
                up= true;
            }
        }
        return count;
    }
}
